<template>
  <div class="main">
    <el-card class="search-box">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
        <el-form-item label="订单号" prop="orderNo">
          <el-input
            v-model="queryParams.orderNo"
            placeholder="请输入订单号"
            clearable
            @keyup.enter.native="getList"
          />
        </el-form-item>
        <el-form-item label="用户信息：" prop="username">
          <el-input
            v-model="queryParams.username"
            placeholder="请输入用户信息"
            clearable
            @keyup.enter.native="getList"
          />
        </el-form-item>
        <el-form-item label="收货人：" prop="receiver">
          <el-input
            v-model="queryParams.receiver"
            placeholder="请输入x姓名/手机号"
            clearable
            @keyup.enter.native="getList"
          />
        </el-form-item>
        <el-form-item label="订单类型" prop="orderType">
          <el-select v-model="queryParams.orderType" placeholder="请选择" clearable>
            <el-option label="商品" :value="1" />
            <el-option label="服务" :value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="创建时间" prop="time">
          <el-date-picker
            v-model="value"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            @change="selectTime"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :default-time="['00:00:00', '23:59:59']"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="getList"
            >查询</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </el-card>
    <el-card>
      <!-- <el-table
        :data="orderList"
        :header-cell-style="{
          background: '#f5f7fa',
          color: '#000000',
        }"
        style="width: 100%"
        border=""
      >
        <el-table-column prop="goodsName"  width="400" label="订单信息">
          <template slot-scope="scope">
            <div class="msg">
              <img :src="scope.row.thumb" alt="">
              <div class="info">
                <p>
                  <span>{{scope.row.title}}</span>
                  <span>{{'¥'+scope.row.orderAmount}}</span>
                </p>
                <p>
                  <span>{{scope.row.subTitle}}</span>
                  <span>{{scope.row.quantity}}</span>
                </p>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="parentCategoryName" label="收货信息">
          <template slot-scope="scope">
            <div class="msgTwo">
              <p>买家：{{scope.row.buyer}}</p>
              <p>收货人：{{scope.row.buyer}}</p>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态"> </el-table-column>
        <el-table-column prop="orderType" label="订单类型"> </el-table-column>
        <el-table-column prop="address" label="操作"> 
          <template slot-scope="scope">
            <el-button  size="mini" type="primary" @click="handleUpdate(scope.row.id)">
              订单详情
            </el-button>
          </template>
        </el-table-column>
      </el-table> -->
      <table cellspacing="0" cellpadding="0" border="0" class="el-table__header" style="width: 100%;">
        <thead class="has-gutter" >
          <tr class="header-table" style="line-height:40px;font-size:18px">
            <th colspan="1" rowspan="1" class="el-table_2_column_5 is-leaf" style="font-weight:bold;"><div class="cell">订单信息</div></th>
            <th colspan="1" rowspan="1" class="el-table_2_column_6 is-leaf" style="font-weight:bold;"><div class="cell">收货信息</div></th>
            <th colspan="1" rowspan="1" class="el-table_2_column_7 is-leaf" style="font-weight:bold;"><div class="cell">状态</div></th>
            <th colspan="1" rowspan="1" class="el-table_2_column_8 is-leaf" style="font-weight:bold;"><div class="cell">操作</div></th>
            </tr>
        </thead>
        <tbody>
          <template v-for="(i,index) in orderList" >
    
            <tr class="el-table__row" :key="index+i.date" style="height:40px;">
              <td rowspan="1" colspan="2" style="text-align:left;padding-left:20px;" class="el-table_4_column_13  "><div class="cell"> <p>下单时间: {{i.orderTime}}订单编号: {{i.orderNo}}</p></div></td>
           
             
              <td rowspan="1" colspan="2" style="text-align:right;padding-right:20px;" class="el-table_4_column_16  "><div class="cell"> <p>共{{i.quantity}}件商品，合计: ¥{{i.orderAmount}}（含运费: ¥{{i.expressFee}} ）</p></div>
              </td>
            </tr>
    
           <tr class="el-table__row" :key="index" style="height:35px;text-align:left">
              <td rowspan="1" colspan="4" class="el-table_3_column_9  "><div class="cell">
                  <div class="spanitem" style="display: flex;">
                    <div class="td-box">
                      <div class="msg">
                        <img :src="i.thumb" alt="">
                        <div class="info">
                          <p>
                            <span>{{i.title}}</span>
                            <span>{{'¥'+i.orderAmount}}</span>
                          </p>
                          <p>
                            <span>{{i.subTitle}}</span>
                            <span>{{i.quantity}}</span>
                          </p>
                        </div>
                      </div>
                    </div>
                    <div class="td-box">
                      <p>买家：{{i.buyer}}</p>
                      <p>收货人：{{i.buyer}}</p>
                    </div>
                    <div class="td-box">
                      {{i.status}}
                    </div>
                    <div class="td-box">
                      <div>
                        <el-button  size="mini" type="primary" @click="goDetails(i.id)">
                          订单详情
                        </el-button>
                      </div>
   
                    </div>
                  </div>
                </div>
              </td>
            </tr> 

          </template>
        </tbody>
      </table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNumber" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </el-card>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import {queryOrderList,queryOrderStatus} from '@/api/order'
export default {
  name: "",
  components: {Pagination},
  props: {},
  data() {
    return {
      queryParams: {
        pageNumber:1,
        pageSize:10,
        startTime:'',
        endTime:'',
        orderNo:'',
        username: '',
        receiver: '',
        orderType: '',
        status: '',
      },
      statusList:[],
      orderList:[],
      value:'',
      total:0
    };
  },
  watch: {},
  computed: {},
  methods: {
    async getStatusData(){
      const res = await queryOrderStatus();
      this.queryOrderStatus = res.data
    },
    async getList(){
      const res = await queryOrderList(this.queryParams);
      this.orderList = res.data.list
      this.total = res.data.total
    },
    selectTime(val){
      this.queryParams.startTime = val[0]+''
      this.queryParams.endTime = val[1]+''
    },
    resetQuery() {
      this.queryParams= {
        pageNumber:1,
        pageSize:10,
        startTime:'',
        endTime:'',
        orderNo:'',
        username: '',
        receiver: '',
        orderType: '',
        status: '',
      },
      this.getList()
    },
    goDetails(orderId){
      this.$router.push({path:'/order/orderDetails',query: {orderId}})
    }
  },
  created() {
    this.getStatusData()
    this.getList()
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
::v-deep .has-gutter{
  padding-bottom: 10px;
}
  ::v-deep .td-box{
    width: 25%;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .msg{
    display: flex;
    img{
      width: 100px;
    }
    .info{
      padding: 0 20px;
      box-sizing: border-box;
      p{
        display: flex;
        width: 250px;
        justify-content: space-between;
        span:nth-child(1){
          display: block;
          width: 150px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
    }
  }
  .msgTwo{
    display: flex;
    flex-direction: column;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  ::v-deep  td{
    width: 25%;
  }
  ::v-deep  .el-table__row:nth-child(odd){
    width: 100%;
    padding: 0;
    background-color: #f5f7fa;

  }
  ::v-deep  .el-table__row:nth-child(odd) td{
    padding: 0;
  }
  ::v-deep  .el-table__row:nth-child(even)::hover{
    background-color: #fff;
  }
</style>